﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TerhelesEloszto.Common;
using TerhelesEloszto.Engine;

namespace Presentation
{
	public partial class TeacherDefault : System.Web.UI.Page
	{
		private ITeacher me;

		protected global::TerhelesEloszto.Engine.IEngine engine = global::TerhelesEloszto.Engine.Engine.Instance();

		protected void Page_Load( object sender, EventArgs e )
		{
			try
			{
				String visitorName = User.Identity.Name;
				if( !engine.IsTeacher( visitorName ) )
				{
					if( engine.IsAdmin( visitorName ) )
					{
						Response.Redirect( "~/Teacher/AdminProblem.aspx" );
					}
					else
					{
						Response.Redirect( "~/Problem.aspx" );
					}

				}
				else
				{
					me = engine.GetTeacherProfile( visitorName );
					Label1.Text = me.Name.Trim();

					string msg = Request["message"];
					if( msg == "ok" )
					{
						Label2.Text = "Sikeres adatmódosítás.";
					}
				}
			}
			catch( EngineException ex )
			{
				Response.Redirect( "~/Teacher/Error.aspx" );
			}
		}
	}
}